# Contributor: Sandro Jäckel <sandro.jaeckel@posteo.de>
# Contributor: Sergei Lukin <sergej.lukin@gmail.com>
# Contributor: Carlo Landmeter <clandmeter@alpinelinux.org>
# Maintainer: Carlo Landmeter <clandmeter@alpinelinux.org>
pkgname=wget
pkgver=1.24.5
pkgrel=0
pkgdesc="Network utility to retrieve files from the Web"
url="https://www.gnu.org/software/wget/wget.html"
arch="all"
license="GPL-3.0-or-later WITH OpenSSL-Exception"
makedepends="libidn2-dev openssl-dev>3 perl zlib-dev pcre2-dev"
checkdepends="perl-http-daemon"
subpackages="$pkgname-doc"
source="https://ftp.gnu.org/gnu/wget/wget-$pkgver.tar.gz"

# secfixes:
#   1.20.3-r0:
#     - CVE-2019-5953
#   1.20.1-r0:
#     - CVE-2018-20483
#   1.19.5-r0:
#     - CVE-2018-0494
#   1.19.1-r1:
#     - CVE-2017-6508
#   1.19.2-r0:
#     - CVE-2017-13090

build() {
	CFLAGS="$CFLAGS -flto=auto" \
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
		--with-libidn \
		--with-ssl=openssl \
		--disable-nls
	make
}

check() {
	# FIXME: We're not running top-level "check" to skip fuzz tests that
	# are currently broken.
	make -C tests check
}

package() {
	make DESTDIR="$pkgdir" install

	rm -rf "$pkgdir"/usr/lib
}

sha512sums="
572aa54717e51a9eb9959e127c7afb696645088f32ff7df2cfe9d243957e34ee235e98988fa94649df023d2e3d62b6973e8c9f2eb92beba820dd96d5de2a950d  wget-1.24.5.tar.gz
"
